/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.uniminuto.Videominuto.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author JULIAN
 */
@Entity
@Table(name = "coleccion")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Coleccion.findAll", query = "SELECT c FROM Coleccion c"),
    @NamedQuery(name = "Coleccion.findByIsanCol", query = "SELECT c FROM Coleccion c WHERE c.isanCol = :isanCol"),
    @NamedQuery(name = "Coleccion.findByTitulo", query = "SELECT c FROM Coleccion c WHERE c.titulo = :titulo"),
    @NamedQuery(name = "Coleccion.findByVolumen", query = "SELECT c FROM Coleccion c WHERE c.volumen = :volumen")})
public class Coleccion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "isan_col")
    private Integer isanCol;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "titulo")
    private String titulo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "volumen")
    private int volumen;
    @JoinTable(name = "coleccion_video", joinColumns = {
        @JoinColumn(name = "isan_col", referencedColumnName = "isan_col")}, inverseJoinColumns = {
        @JoinColumn(name = "isan_vdi", referencedColumnName = "isan_video")})
    @ManyToMany
    private List<Video> videoList;

    public Coleccion() {
    }

    public Coleccion(Integer isanCol) {
        this.isanCol = isanCol;
    }

    public Coleccion(Integer isanCol, String titulo, int volumen) {
        this.isanCol = isanCol;
        this.titulo = titulo;
        this.volumen = volumen;
    }

    public Integer getIsanCol() {
        return isanCol;
    }

    public void setIsanCol(Integer isanCol) {
        this.isanCol = isanCol;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public int getVolumen() {
        return volumen;
    }

    public void setVolumen(int volumen) {
        this.volumen = volumen;
    }

    @XmlTransient
    public List<Video> getVideoList() {
        return videoList;
    }

    public void setVideoList(List<Video> videoList) {
        this.videoList = videoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (isanCol != null ? isanCol.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Coleccion)) {
            return false;
        }
        Coleccion other = (Coleccion) object;
        if ((this.isanCol == null && other.isanCol != null) || (this.isanCol != null && !this.isanCol.equals(other.isanCol))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.edu.uniminuto.Videominuto.entities.Coleccion[ isanCol=" + isanCol + " ]";
    }
    
}
